export default getBackgroundColor = (path) => {
  const canvas = this.$refs.canvas;
  const context = canvas.getContext("2d");
  const img = new Image();
  img.src = path;
  img.onload = () => {
    canvas.width = img.width;
    canvas.height = img.height;
    context.drawImage(img, 0, 0);
    const imageData = context.getImageData(0, 0, canvas.width, canvas.height);
    const data = imageData.data;
    const x = 0; // 选择图片的某个像素，或者遍历所有像素来获取多个颜色
    const y = 0;
    const index = (y * canvas.width + x) * 4;
    const red = data[index];
    const green = data[index + 1];
    const blue = data[index + 2];
    const alpha = data[index + 3];
    const color = `rgba(${red}, ${green}, ${blue}, ${alpha})`;
    console.log("Background color:", color);
    // 处理color，例如应用到某个元素的样式等
  };
};
